package com.taoyibao.hongcanting.ui.login.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.taoyibao.hongcanting.R;
import com.taoyibao.hongcanting.base.activity.BaseActivityNoSlidePresenter;
import com.taoyibao.hongcanting.cache.SpUtils;
import com.taoyibao.hongcanting.constant.CodeConstant;
import com.taoyibao.hongcanting.ui.MainActivity;
import com.taoyibao.hongcanting.ui.admin.activity.AdministratorActivity;
import com.taoyibao.hongcanting.ui.admin.activity.WaiterActivity;
import com.taoyibao.hongcanting.ui.login.delegate.WelcomeDelegate;

/**
 * @author TangAnna
 * @description: 欢迎页面
 * @date :${DATA} 16:38
 */
public class WelcomeActivity extends BaseActivityNoSlidePresenter<WelcomeDelegate> implements View.OnClickListener {
    @Override
    protected Class<WelcomeDelegate> getDelegateClass() {
        return WelcomeDelegate.class;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        viewDelegate.setSupportFragmentManager(getSupportFragmentManager());
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void bindEvenListener() {
        super.bindEvenListener();
        viewDelegate.get(R.id.tv_start).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_start://开始
                SpUtils.putWelcomeStatus(false);//更新欢迎页面的状态
                if (SpUtils.getUserType() == CodeConstant.USER_TYPE_USER) {//普通用户
                    startActivity(new Intent(this, MainActivity.class));
                } else if (SpUtils.getUserType() == CodeConstant.USER_TYPE_SCREEN_OPERATOR) {//屏幕操作员
                    startActivity(new Intent(this, AdministratorActivity.class));
                } else if (SpUtils.getUserType() == CodeConstant.USER_TYPE_WAITER) {//服务员
                    startActivity(new Intent(this, WaiterActivity.class));
                } else {
                    startActivity(new Intent(this, MainActivity.class));
                }
                finish();
                break;
        }
    }

}
